﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "textedit.h"
#include <QMdiSubWindow>
#include <QPrinter>
#include <QActionGroup>
#include <QSignalMapper>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    void init();
    void initFontSize();
    void initScrollBar();
    TextEdit* activateWindow();
    void initDocAction();
    QMdiSubWindow* findSubWindow(const QString&docName);


protected:
    void closeEvent(QCloseEvent*event)override;

private slots:
    void initWindowAction();
    void on_newAction_triggered();
    void setActionStatus(bool);

    void on_openAction_triggered();

    void on_saveAction_triggered();

    void on_saveAsAction_triggered();

    void on_printAction_triggered();

    void on_printViewAction_triggered();

    void paintPreview(QPrinter*printer);

    void on_undoAction_triggered();

    void on_redoAction_triggered();

    void on_pasteAction_triggered();

    void on_cutAction_triggered();

    void on_copyAction_triggered();

    void on_exitAction_triggered();

    void on_closeAction_triggered();

    void on_closeAllAction_triggered();

    void on_tittleAction_triggered();

    void on_cascadAction_triggered();

    void on_nextAction_triggered();

    void on_previousAction_triggered();

    void addSubWindowAction();

    void setActiveSubWindow(QWidget*widget);

    void on_colorAction_triggered();

    void on_boldAction_triggered();

    void on_italicAction_triggered();

    void on_underlineAction_triggered();

    void on_leftAlignAction_triggered();

    void on_centerAction_triggered();

    void on_rightAlignAction_triggered();

    void on_justifyAction_triggered();

    void on_comboBox_activated(int index);

    void on_fontComboBox_activated(const QString &arg1);

    void on_sizeComboBox_activated(const QString &arg1);

    void setFuXuan();

private:
    Ui::MainWindow *ui;
    QActionGroup*actionGroup;
    QSignalMapper*mapper;
};
#endif // MAINWINDOW_H
